/*Policies in PFTZs
treat_post(Pilot Free Trade Zone Dummy Variable)
scale(Sum of principal component scores of financial institutions' deposit and loan scales)
stability(Logarithm of the ratio of time deposits to demand deposits)
treat_post(Pilot Free Trade Zone Dummy Variable)
pop u_area gr fie co pat
indexDig(Digitalization of Digital Inclusive Finance)
indexB(Breadth of Digital Inclusive Finance)
indexD(Depth of Digital Inclusive Finance) */
clear
import excel "C:\Users\jiang\Desktop\submit\data.xlsx", sheet("Sheet2") firstrow
cd C:\Users\jiang\Desktop\submit
***Test for Multicollinearity
reg pop u_area gr fie co pat
estat vif
***Descriptive Statistics
logout ,save(tabel3) word replace: tabstat scale stability treat_post pop u_area gr fie co pat indexDig indexB indexD , s(N mean sd min max) f(%12.3f) c(s)



***Promoting Effects
xtset region year
xtreg scale treat_post i.year,fe
est sto r11
xtreg scale treat_post pop u_area gr fie co pat i.year,fe
est sto r12
esttab r11 r12 using C:\Users\jiang\Desktop\submit\table4.rtf, b(%12.3f) se(%12.3f) star(* 0.10 ** 0.05 *** 0.01) nogap compress s(N r2)
***Parallel Trends Test of Promoting Effects
gen pd=year-time if treat==1
tab pd
forvalues i=9(-1)1{
	gen p_`i'=(pd==-`i') if treat==1
}
gen current=(pd==0)
forvalues i=1(1)9{
	gen l_`i'=(pd==`i') if treat==1
}
replace p_4=1 if p_5==1|p_6==1|p_7==1|p_8==1|p_9==1
replace l_6=1 if l_7==1|l_8==1|l_9==1
xtreg scale pop u_area fie co pat gr p_4 p_3 p_2 current l_1 l_2 l_3 l_4 l_5 l_6 i.year,fe
est store reg1
coefplot reg1,keep (p_* current l_*) vertical coeflabels(p_4=t-4 p_3=t-3 p_2=t-2 current=t l_1=t+1 l_2=t+2 l_3=t+3 l_4=t+4 l_5=t+5 l_6=t+6) yline(0,lwidth(vthin) lpattern(dash) lcolor(teal)) xline(4,lwidth(vthin) lpattern(dash) lcolor(cranberry)) ylabel(,labsize(*0.75) angle(0)) xlabel(,labsize(*0.75)) ytitle("Policy Effect") xtitle("Period") msymbol(0) msize(small) mcolor(navy) addplot(line @b @at, lp(dash) lwidth(*0.5)) ciopts(lpattern(solid) lcolor(navy) recast(rcap) msize(medium)) graphregion(color(white))
graph export "figure2.png", width(1000)
***Placebo Test of Promoting Effects
permute treat_post beta=_b[treat_post] se=_se[treat_post] dr=e(df_r) ,rep(1000) saving("x1.dta"): xtreg scale treat_post pop u_area gr fie co pat i.year,fe
clear
use x1.dta
gen t_value=beta/se
gen p_value=2*ttail(dr,abs(beta/se))
twoway (scatter p_value beta,msymbol (smcircle_hollow) msize(small) mcolor(dash))(kdensity beta,yaxis(2)), ytitle("density") xtitle("placebo-estimated coefficient") xline(0.234,lcolor(cranberry) lp(dash)) yline(0.01) xlabel(-0.3(0.1)0.3) graphregion(color(white))
graph export "figure3.png", width(1000)
***Mediation Analysis Results of the Promoting Effect
clear
import excel "C:\Users\jiang\Desktop\submit\data.xlsx", sheet("Sheet2") firstrow
cd C:\Users\jiang\Desktop\submit
xtset region year
xtreg indexDig treat_post i.year,fe
est sto r21
xtreg indexDig treat_post pop u_area gr fie co pat i.year,fe
est sto r22
esttab r21 r22 using C:\Users\jiang\Desktop\submit\table5.rtf, b(%12.3f) se(%12.3f) star(* 0.10 ** 0.05 *** 0.01) nogap compress s(N r2)



***Inhibitory Effects
clear
import excel "C:\Users\jiang\Desktop\submit\data.xlsx", sheet("Sheet2") firstrow
cd C:\Users\jiang\Desktop\submit
xtset region year
xtreg stability treat_post i.year,fe
est sto r41
xtreg stability treat_post pop u_area gr fie co pat i.year,fe
est sto r42
esttab r41 r42 using C:\Users\jiang\Desktop\submit\table6.rtf, b(%12.3f) se(%12.3f) star(* 0.10 ** 0.05 *** 0.01) nogap compress s(N r2)
***Parallel Trends Test of Inhibitory Effects
gen pd=year-time if treat==1
tab pd
forvalues i=9(-1)1{
	gen p_`i'=(pd==-`i') if treat==1
}
gen current=(pd==0)
forvalues i=1(1)9{
	gen l_`i'=(pd==`i') if treat==1
}
replace p_4=1 if p_5==1|p_6==1|p_7==1|p_8==1|p_9==1
replace l_6=1 if l_7==1|l_8==1|l_9==1
xtreg stability pop u_area gr fie co pat gr p_4 p_3 p_2 current l_1 l_2 l_3 l_4 l_5 l_6 i.year,fe
est store reg2
coefplot reg2,keep (p_* current l_*) vertical coeflabels(p_4=t-4 p_3=t-3 p_2=t-2 current=t l_1=t+1 l_2=t+2 l_3=t+3 l_4=t+4 l_5=t+5 l_6=t+6) yline(0,lwidth(vthin) lpattern(dash) lcolor(teal)) xline(4,lwidth(vthin) lpattern(dash) lcolor(cranberry)) ylabel(,labsize(*0.75) angle(0)) xlabel(,labsize(*0.75)) ytitle("Policy Effect") xtitle("Period") msymbol(0) msize(small) mcolor(navy) addplot(line @b @at, lp(dash) lwidth(*0.5)) ciopts(lpattern(solid) lcolor(navy) recast(rcap) msize(medium)) graphregion(color(white))
graph export "figure4.png", width(1000)
***Placebo Test of Inhibitory Effects
permute treat_post beta=_b[treat_post] se=_se[treat_post] dr=e(df_r) ,rep(1000) saving("x2.dta"): xtreg stability treat_post pop u_area fie co pat gr i.year,fe
clear
use x2.dta
gen t_value=beta/se
gen p_value=2*ttail(dr,abs(beta/se))
twoway (scatter p_value beta,msymbol (smcircle_hollow) msize(small) mcolor(dash))(kdensity beta,yaxis(2)), ytitle("density") xtitle("placebo-estimated coefficient") xline(-0.180,lcolor(cranberry) lp(dash)) yline(0.01) xlabel(-0.3(0.1)0.3) graphregion(color(white))
graph export "figure5.png", width(1000)
***Mediation Analysis Results of the Inhibitory Effect
clear
import excel "C:\Users\jiang\Desktop\submit\data.xlsx", sheet("Sheet2") firstrow
cd C:\Users\jiang\Desktop\submit
xtset region year
xtreg indexB treat_post i.year,fe
est sto r51
xtreg indexB treat_post pop u_area gr fie co pat i.year,fe
est sto r52
xtreg indexD treat_post i.year,fe
est sto r53
xtreg indexD treat_post pop u_area fie gr co pat i.year,fe
est sto r54
esttab r51 r52 r53 r54 using C:\Users\jiang\Desktop\submit\table7.rtf, b(%12.3f) se(%12.3f) star(* 0.10 ** 0.05 *** 0.01) nogap compress s(N r2)



***Regional Heterogeneity Test of the Promotional Effect（1Northern Region&2Central-Southern Region）
clear
import excel "C:\Users\jiang\Desktop\submit\data.xlsx", sheet("Sheet2") firstrow
cd C:\Users\jiang\Desktop\submit
keep if areagroup==1
xtset region year
xtreg scale treat_post pop u_area gr fie co pat i.year,fe 
est sto r31
esttab r31 using C:\Users\jiang\Desktop\submit\table9_1.rtf, b(%12.3f) se(%12.3f) star(* 0.10 ** 0.05 *** 0.01) nogap compress s(N r2)
clear
import excel "C:\Users\jiang\Desktop\submit\data.xlsx", sheet("Sheet2") firstrow
cd C:\Users\jiang\Desktop\submit
keep if areagroup==2
xtset region year
xtreg scale treat_post pop u_area gr fie co pat i.year,fe 
est sto r32
esttab r32 using C:\Users\jiang\Desktop\submit\table9_2.rtf, b(%12.3f) se(%12.3f) star(* 0.10 ** 0.05 *** 0.01) nogap compress s(N r2)
***Regional Heterogeneity Test of the  Inhibitory Effect（1Northern Region&2Central-Southern Region）
clear
import excel "C:\Users\jiang\Desktop\submit\data.xlsx", sheet("Sheet2") firstrow
cd C:\Users\jiang\Desktop\submit
keep if areagroup==1
xtset region year
xtreg stability treat_post pop u_area gr fie co pat i.year,fe 
est sto r61
esttab r61 using C:\Users\jiang\Desktop\submit\table10_1.rtf, b(%12.3f) se(%12.3f) star(* 0.10 ** 0.05 *** 0.01) nogap compress s(N r2)
clear
import excel "C:\Users\jiang\Desktop\submit\data.xlsx", sheet("Sheet2") firstrow
cd C:\Users\jiang\Desktop\submit
keep if areagroup==2
xtset region year
xtreg stability treat_post pop u_area gr fie co pat i.year,fe 
est sto r62
esttab r62 using C:\Users\jiang\Desktop\submit\table10_2.rtf, b(%12.3f) se(%12.3f) star(* 0.10 ** 0.05 *** 0.01) nogap compress s(N r2)




